$(document).ready(function() {
	$(".bnt_frm").click(function() {
		 var cardno = $("#cardno").val();
     var amount = $("#amount").val();
     var password = $("#password").val();
     if (cardno =="") {
     	jAlert("请填写卡号","充值失败","");
     	return false;
     }else if(amount ==""){
     	jAlert("请填写金额","充值失败","");
     	return false;
     }else if(password ==""){
      jAlert("请填写主管密码","充值失败","");
      return false;
     }
		$.ajax({
           url: "index.php?go=softpos.api.ajaxKcz",
           type: 'post',
           dataType: 'json',
           data:$("#frm").serialize(),
           success: function(response) {
               if (response.success == "success") {
                   jAlert(response.data,"充值成功",function(r) {
                       if (r==true) {
                          $("#cardno_show").html(cardno);
                          $("#amount_show").html(amount);
                          var myDate = new Date();
                          var ymd = myDate.toLocaleDateString(); 
                          var mytime=myDate.toLocaleTimeString();
                          $("#date_show").html(ymd);
                          $("#time_show").html(mytime);
                          var member = response.member;
                            $("#balance_show").html(member.user_balance);
                            $("#point_show").html(member.user_point);
                          
	                        $(".shadow").show();
							            $("#hidden_form").show();	
                       }
                   });
               } else {
                   jAlert(response.data,"充值失败","");
               }
           }
       });
	});
	
	$(".hidden_form_top_r").click(function(){
        location.reload();
        $(".shadow").hide();
        $("#hidden_form").hide();
    })
    $(".sendSms").click(function(){
        var contents = "卡号："+$("#cardno").val()+" 本次充值："+$("#amount").val()+"元";
        var user_mobile =$("#user_mobile").val();
        var data = {mobile:user_mobile,contents:contents};
        $.ajax({
            url: "index.php?go=softpos.api.sendSms",
            type: 'post',
            dataType: 'json',
            data:data,
            success: function(response) {
                if (response.success == "success") {
                    jAlert("发送成功","发送成功",function(r) {
                        if (r==true) {
                           location.reload(); 
                        }
                    });
                } else {
                    jAlert(response.data,"发送失败","");
                }
            }
        });
    });
    $(".sendwx").click(function(){
        var contents = "卡号："+$("#cardno").val()+" 本次充值："+$("#amount").val()+"元";
        var user_mobile =$("#user_mobile").val();
        var data = {mobile:user_mobile,contents:contents};
        $.ajax({
            url: "index.php?go=softpos.api.sendWx",
            type: 'post',
            dataType: 'json',
            data:data,
            success: function(response) {
                if (response.success == "success") {
                    jAlert("发送成功","发送成功",function(r) {
                        if (r==true) {
                           location.reload(); 
                        }
                    });
                } else {
                    jAlert(response.data,"发送失败","");
                }
            }
        });
    });
});